package com.example.schedulemanager.database;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.schedulemanager.model.Schedule;

import java.util.List;

@Dao
public interface ScheduleDao {
    
    @Insert
    long insert(Schedule schedule);
    
    @Update
    void update(Schedule schedule);
    
    @Delete
    void delete(Schedule schedule);
    
    @Query("SELECT * FROM schedules ORDER BY date ASC, time ASC")
    LiveData<List<Schedule>> getAllSchedules();
    
    @Query("SELECT * FROM schedules WHERE date = :date ORDER BY isCompleted ASC, time ASC")
    LiveData<List<Schedule>> getSchedulesByDate(String date);
    
    @Query("SELECT * FROM schedules WHERE date >= :currentDate ORDER BY date ASC, time ASC")
    LiveData<List<Schedule>> getUpcomingSchedules(String currentDate);
    
    @Query("SELECT * FROM schedules WHERE id = :id")
    Schedule getScheduleById(int id);
    
    @Query("UPDATE schedules SET isCompleted = :completed WHERE id = :id")
    void updateCompletionStatus(int id, boolean completed);
} 